package utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitMQUtil {
    
    public static Channel getChannel() throws IOException, TimeoutException {
        // 得到连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("192.168.208.134");
        factory.setUsername("admin");
        factory.setPassword("123");
        // 从连接工厂得到一个连接
        Connection connection = factory.newConnection();
        // 从连接中得到一个Channel
        return connection.createChannel();
    }
}
